#pragma once
#include <spdlog/spdlog.h>
#include <spdlog/async.h>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include <memory>
#include <string>

using std::shared_ptr;
using std::string;

class Log
{
public:
    static Log &getInstance();
    void init(const string &path, size_t queSize, int threadnum, size_t maxFileSize, size_t maxFiles);
    void shutdown();

    shared_ptr<spdlog::logger> getLogPtr() { return _logger; }

    template <typename... Args>
    static void trace(const char *fmt, const Args &...args)
    {
        spdlog::trace(fmt, args...);
    }

    template <typename... Args>
    static void debug(const char *fmt, const Args &...args)
    {
        spdlog::debug(fmt, args...);
    }

    template <typename... Args>
    static void info(const char *fmt, const Args &...args)
    {
        spdlog::info(fmt, args...);
    }

    template <typename... Args>
    static void warn(const char *fmt, const Args &...args)
    {
        spdlog::warn(fmt, args...);
    }

    template <typename... Args>
    static void error(const char *fmt, const Args &...args)
    {
        spdlog::error(fmt, args...);
    }

private:
    Log() = default;
    Log(const Log &) = delete;
    Log &operator=(const Log &) = delete;
    static shared_ptr<spdlog::logger> _logger;
};
